import axios from "axios";
import { Loading } from 'element-ui';

const requests = axios.create({
    baseURL: 'https://www.hnzjyxs.com/api/',
    timeout: 1000
})

//请求拦截器
requests.interceptors.request.use(config => {
    setTimeout(() => {
        Loading.service().close();
    }, 1000);
    Loading.service()
    return config
});
//响应拦截器
requests.interceptors.response.use(config => {

    Loading.service().close();
    return config
})

export const request = (url, method, data) => {
    return requests({
        url,
        method,
        data
    })
}